import request from "@/utils/request";
import type {
	HospitalDetailResponseData,
	DepartmentResponseData,
	code,
	LoginData,
	LoginResponseData,
	WxLoginResponseData,
	workData,
	DoctorResponseData,
	UserResponseData, DoctorInfo,
} from "@/api/hospital/type"

enum API {
	HOSPITALDETAIL_URL='/hosp/hospital/',
	HOSPITALDEPARTMENT_URL='/hosp/hospital/department/',
	// 获取验证码
	GETCODE_URL = '/sms/send/',
	// 用户登录接口
	LOGIN_URL = '/user/login',
	// 微信扫码登录参数
	WXLOGIN_URL = '/user/weixin/getLoginParam/',
	// 预约挂号
	REGISTER_URL = '/hosp/hospital/auth/getBookingScheduleRule/',
	// 某个科室某一天上下午医生信息
	DOCTOR_URL = '/hosp/hospital/auth/findScheduleList/',
	// 获取某一个账号下就诊人的信息
	GETUSER_URL = '/user/patient/auth/findAll',
	// 获取挂号医生的信息
	GETDOCTOR_URL = '/hosp/hospital/getSchedule/',
}

// 获取医院详情
export const reqHospitalDetail=(hoscode: string) =>
	request.get<any,HospitalDetailResponseData>(API.HOSPITALDETAIL_URL+hoscode)

// 获取医院的科室
export const reqDepartment= (hoscode: string) =>
	request.get<any,DepartmentResponseData>(API.HOSPITALDEPARTMENT_URL + hoscode )

// 获取验证码
export const reqGetCode=(phone: string) =>
	request.get<any,code>(API.GETCODE_URL + phone);

// 用户登录
export const reqLogin=(data: LoginData) =>
	request.post<any,LoginResponseData>(API.LOGIN_URL,data);

// 微信扫码登录生成二维码参数
export const reqWxLogin=(wxRedirectUri: string) =>
	request.get<any,WxLoginResponseData>(API.WXLOGIN_URL+`?wxRedirectUri=${wxRedirectUri}`);

// 医院可预约挂号数据
export const reqRegister=(page: number,limit: number,hoscode:string,depcode:string) =>
  request.get<any,workData>(
      API.REGISTER_URL + `${page}/${limit}/${hoscode}/${depcode}`
  )

// 某个科室某一天上下午医生信息
export const reqDoctor=(hoscode: string,depcode: string,workDate: string) =>
  request.get<any,DoctorResponseData>(
      API.DOCTOR_URL + `${hoscode}/${depcode}/${workDate}`
  )

// 获取某一个账号下就诊人的信息
export const reqGetUser=() =>
	request.get<any,UserResponseData>(API.GETUSER_URL)

// 获取挂号医生的信息
export const reqDoctorInfo=(Schedule: string) =>
	request.get<any,DoctorInfo>(API.GETDOCTOR_URL + Schedule)

